package cn.wolfcode.p2p.base.domain;

import cn.wolfcode.p2p.business.mapper.PaymentScheduleMapper;
import cn.wolfcode.p2p.util.Constants;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.Arrays;

@Getter
@Setter
public class Account extends BaseDomain {
        private Integer version=0; //版本号
        private String tradePassword;     //交易密码
        private BigDecimal usableAmount= Constants.ZERO;//账户可用余额
        private BigDecimal freezedAmount= Constants.ZERO;//账户冻结金额
        private BigDecimal unReceiveInterest= Constants.ZERO;//账户待收利息
        private BigDecimal unReceivePrincipal= Constants.ZERO;//账户待收本金
        private BigDecimal unReturnAmount= Constants.ZERO;//账户待还金额
        private BigDecimal remainBorrowLimit= Constants.BORROW_LIMIT;//账户剩余授信额度
        private BigDecimal borrowLimitAmount=Constants.BORROW_LIMIT;//账户授信额度


        //获取账户总额 的方法
        public BigDecimal getTotalAmount(){
                return usableAmount.add(freezedAmount).add(unReceiveInterest).add(unReceivePrincipal);
        }
        //加可用余额
        public void addUsableAmount(BigDecimal amout){
                this.usableAmount = this.usableAmount.add(amout);

        }
        //减可用余额
        public void subtractUsableAmount(BigDecimal amout){
                this.usableAmount = this.usableAmount.subtract(amout);

        }
        //增加冻结金额
        public void addFreezedAmount(BigDecimal amout){
                this.freezedAmount = this.freezedAmount.add(amout);

        }


        //较少冻结金额
        public void subtractFreezedAmount(BigDecimal amout){
                addFreezedAmount(amout.negate());//negate是负数-的意思

        }
        public static int[] change(int[] arr,int i,int b){
                int temp = arr[i];
                arr[i] = arr[b];
                arr[b] = temp;
                return arr;
        }
        public static void main(String[] args) {
                int[] ints = {1, 5, 3, 6, 2, 9};
                for(int i = 0;i<ints.length-1;i++){
                        for(int j=0;j<ints.length-i-1;j++){
                                if(ints[j]<ints[j+1]){
                                        ints = change(ints, j,j+1);
                                }
                        }
                }
                System.out.println(Arrays.toString(ints));
        }


}
